/**
 * JAFMIMEService
 *
 * An implementation of MIMEService, using the JavaBeans Activation Framework
 *
 */

package uk.co.sheitgeist.fums.server.app.mime

import javax.activation.MimetypesFileTypeMap
import javax.activation.MimeType

public class JAFMIMEService implements MIMEService {

	private MimetypesFileTypeMap mimetypes

	public JAFMIMEService() {
		mimetypes = new MimetypesFileTypeMap()	
	}

	public JAFMIMEService(java.io.InputStream is) {
		mimetypes = new MimetypesFileTypeMap(is)			
	}
	
	public JAFMIMEService(java.lang.String mimeTypeFileName) {
			mimetypes = new MimetypesFileTypeMap(mimeTypeFileName)	
	}
	public String getContentType(File file) {
		return mimetypes.getContentType(file)
	}

	public String getPrimaryType(File file) {
		return new MimeType(this.getContentType(file)).getPrimaryType()
	}

	public String getSubType(File file) {
		return new MimeType(this.getContentType(file)).getSubType()
	}
}
